package com.atguigu.springcloud.config;


import org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class GatewayConfig {

//    @Bean
    public RouteLocator routeLocator(RouteLocatorBuilder builder) {
        RouteLocatorBuilder.Builder routes = builder.routes();
        routes.route("payment_routh",
                fn -> fn.path("/payment/hystrix/ok/31")
                .uri("http://localhost:8001/payment/hystrix/ok/31")).build();
        routes.route("payment_routh2",
                fn -> fn.path("/guonei")
                        .uri("http://news.baidu.com/guonei")).build();
        routes.route("payment_routh3",
                fn -> fn.path("/guoji")
                        .uri("http://news.baidu.com/guoji")).build();
        return routes.build();
    }
}
